package com.tongji.seller.command
{
	import com.tongji.seller.events.GetStoreItemInfoEvent;
	import com.tongji.seller.model.StoreProductModel;
	import com.tongji.seller.service.StoreProductService;
	
	import org.robotlegs.mvcs.Command;
	
	/**
	 * 
	 * @author jiarong
	 * 2011-12-6
	 *
	 */
	
	public class GetStoreItemInfoCommand extends Command
	{
		[Inject]
		public var event:GetStoreItemInfoEvent;
		
		[Inject]
		public var service:StoreProductService;
		
		[Inject]
		public var model:StoreProductModel;
		
		public function GetStoreItemInfoCommand()
		{
			super();
		}
		
		override public function execute():void
		{
			switch(event.type)
			{
				case GetStoreItemInfoEvent.GET_STORE_ITEM:
					service.getStoreItem(event.userId, event.page_no, event.pageSize);
					break;
				case GetStoreItemInfoEvent.UPDATE_STORE_ITEM:
					model.updateStoreItem(event.product);
					break;
				case GetStoreItemInfoEvent.GET_STORE_PRODUCT:
					service.getStoreProduct(event.userId, event.page_no, event.pageSize);
					break;
				case GetStoreItemInfoEvent.UPDATE_STORE_PRODUCT:
					model.updateStoreProduct(event.product);
					
			}
		}
	}
}